/* ----------------------------------------------------------------------------------------------------------------------------------------------- /

NumberTool - 类名称
修改许可权限 - 修改人名称

< --- Public Vars ------------------------------------------------------------------------------------------------------------------------------ >

< --- Public Functions ------------------------------------------------------------------------------------------------------------------------ >

※ 构造函数
public function NumberTool()

/ ----------------------------------------------------------------------------------------------------------------------------------------------- */
package editor.util{
	import editor.map.TileLayer;
	import editor.map.elements.Tile;
	
	import flash.geom.Point;

	public class NumberTool{
		
		
		/**
		 * 将目标数组限制在一个范围内
		 * @param target
		 * @param min
		 * @param max
		 * @return  
		 */		
		public static function limitInt(target:int, min:int, max:int):int
		{
			if(target < min) target = min;
			if(target > max) target = max;
			return target;
		}
		
		public static function p2lTransform(px:int, py:int):Point
		{
			px = limitInt(px, 0, Tile.TILE_WIDTH * TileLayer.MAP_LOGIC_WIDTH);
			py = limitInt(py, 0, Tile.TILE_WIDTH * TileLayer.MAP_LOGIC_HEIGHT);
			
			var point:Point = new Point();
			point.x = int(px / Tile.TILE_WIDTH);
			point.y = int(py / Tile.TILE_WIDTH);
			return point;
		}
		
		//
	}
}